package com.Maykk.charStream;


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @ClassName: Demo04
 * @Description: TODO 字符流读取 - read()
 * @Author: MaykkStar@163.com
 */
public class Demo04 {
    public static void main(String[] args) throws IOException {
        // FileInputStream fis = new FileInputStream("./Maykk.txt");
        InputStreamReader ir = new InputStreamReader(new FileInputStream("./Maykk.txt"));
        // 一次读一个字符
        int c;
        while ((c = ir.read()) != -1)
            System.out.print((char) c);

        System.out.println("\n==============================");
        // 一次读一个字符数组
        char[] ch = new char[1024];
        int len;
        while ((len = ir.read(ch)) != -1)
            System.out.print(new String(ch, 0, len));

        ir.close();
    }
}
